package cn.diancan.model.types;

import java.util.ArrayList; 
import java.util.List;

public enum PurchaseSaleOrderProductStatusType {
    
    PURCHASE	(11,"进货",TranUseType.ADDMONEY,true),

    INVENTORY	(12,"盘点",TranUseType.ADDMONEY,true),
    
    
    SALE	(21,"销售",TranUseType.ADDMONEY,true),
    
    GIFT	(22,"赠品",TranUseType.SUBNONEY,false),
    
    RETURNGOODS	(24,"退货",TranUseType.SUBNONEY,true);
    
    
    private PurchaseSaleOrderProductStatusType(Integer type, String typeName,   Integer useType, boolean operating) {
		this.type = type;
		this.typeName = typeName;
		this.useType = useType;
		this.operating = operating;
    }
    
    public static PurchaseSaleOrderProductStatusType[] getSaleValues(){
	PurchaseSaleOrderProductStatusType enums[] =PurchaseSaleOrderProductStatusType.values();
	List<PurchaseSaleOrderProductStatusType> list =new ArrayList<PurchaseSaleOrderProductStatusType>();
	for (int i = 0; i < enums.length; i++) {
	    PurchaseSaleOrderProductStatusType singleEnum=  enums[i]; 
	    if(singleEnum.getType() >20 &&singleEnum.getType() <30){
		list.add(singleEnum);
	    }
	}
	
	return list.toArray(new PurchaseSaleOrderProductStatusType[]{});
	
    }
    
    public static boolean checkExists(Integer type){
	if(null==type){
	    return false;
	}
	PurchaseSaleOrderProductStatusType enums[] =PurchaseSaleOrderProductStatusType.values();
	for (int i = 0; i < enums.length; i++) {
	    PurchaseSaleOrderProductStatusType singleEnum=  enums[i]; 
	    if(singleEnum.getType().equals(type)){
		return true;
	    }
	}
	return false;
    }
    
    public static PurchaseSaleOrderProductStatusType find(Integer type){
   	if(null==type){
   	    return null;
   	}
   	PurchaseSaleOrderProductStatusType enums[] =PurchaseSaleOrderProductStatusType.values();
   	for (int i = 0; i < enums.length; i++) {
   	    PurchaseSaleOrderProductStatusType singleEnum=  enums[i]; 
   	    if(singleEnum.getType().equals(type)){
   		return singleEnum;
   	    }
   	}
   	return null;
     }
    
    
    private Integer type;
    private String typeName; 
    private Integer useType; //1.加钱     2.扣钱  (以钱包里面的钱为准)
    private boolean operating; //不加不减（赠送）
    
    public Integer getType() {
        return type;
    }
    public String getTypeName() {
        return typeName;
    }


    public Integer getUseType() {
        return useType;
    }
    public boolean isOperating() {
        return operating;
    }

 

}
